home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
cad
/
acadlsp.zip
/
EDIT.LSP
< prev
next >
Wrap
Text File
|
1987-09-28
|
10KB
|
329 lines
; EDIT Version 1.0
; Copyright 1987 Alacrity
;
; Jason Osgood
; 12405 SE 25th
; Bellevue, WA. 98005
;
; CompuServe ID: 73417,1756
(defun *error* (msg)
(princ "\nerror: ")
(princ msg)
(terpri)
)
(defun c:EDIT (/ char ss p1 p2 linlst num i len p lst ins tab new old txt str
txtlin item ent entdata txtlst entlst insert delete brktxt
jointxt deltxt modtxt chglin status cursor mode comlin
display)
(setq tab (strcat "+" (chr 205) (chr 205) (chr 205) (chr 205))
i 0 p 1 num 0 linlst (list) txtlst (list) entlst (list) txtlin 0)
(setvar "CmdEcho" 0)
(princ " Version 1.0 (c)1987 Alacrity")
(defun delete (lst i)
(cond ((zerop i) (cdr lst))
(T (cons (car lst) (delete (cdr lst) (1- i))))
)
)
(defun insert (lst item i)
(cond ((zerop i) (cons item lst))
(T (cons (car lst) (insert (cdr lst) item (1- i))))
)
)
(defun modtxt (txtlin txt old)
(princ "\e[2J")
(repeat 24 (terpri))
(graphscr)
(entmod (subst (cons 1 txt) (cons 1 old) (entget (nth txtlin entlst))))
(setq txtlst (insert (delete txtlst txtlin) txt txtlin))
(getstring "Press [ENTER] to continue.")
(display)
)
(defun comlin ()
(princ "\e[2;1H")
(princ "\e[K")
)
(defun mode (i)
(setq ins (not i))
(princ "\e[s")
(princ "\e[2;8H")
(princ (if ins "ON " "OFF"))
(princ "\e[u")
)
(defun cursor ()
(princ "\e[2;32H")
(princ p)
(princ " ")
(princ "\e[")
(princ (+ 4 (* 2 txtlin)))
(princ ";")
(princ p)
(princ "H")
)
(defun status ()
(comlin)
(princ "Insert ")
(princ (if ins "ON " "OFF"))
(princ " Line ")
(princ (1+ txtlin))
(princ " ")
(princ "\e[2;25H")
(princ "Column ")
(princ p)
(princ " \n")
)
(defun chglin (i)
(if (/= old txt) (modtxt txtlin txt old))
(setq txtlin (+ i txtlin) p 1 txt (nth txtlin txtlst) old txt
len (strlen txt))
(princ "\e[2;20H")
(princ (1+ txtlin))
(princ " ")
(cursor)
)
(defun display ()
(textscr)
(princ "\e[2J")
(princ (strcat "EDIT (C)1987 Alacrity F2-Mod F3-Join F4-Brk F5-" (chr 30)
" F6-" (chr 31) " F7-" (chr 17) " F8-" (chr 16) " F9-Del F10-Ins\n"))
(status)
(repeat 16 (princ tab))
(mapcar '(lambda (str) (princ (strcat str "\004\n\n"))) txtlst)
)
(defun deltxt ()
(princ "\e[2J")
(repeat 24 (terpri))
(graphscr)
(entdel (nth txtlin entlst))
(setq txtlst (delete txtlst txtlin) entlst (delete entlst txtlin)
num (1- num) txt nil old nil)
(display)
(if (> num 0)
(if (= txtlin 0)
(chglin 0)
(progn
(setq txtlin (1- txtlin))
(chglin -1)
)
)
)
)
(defun jointxt ()
(comlin)
(if (and (setq i (getint "Join line number: "))
(/= (1- i) txtlin) (< (1- i) num) (> i 0))
(progn
(setq i (1- i))
(princ "\e[2J")
(repeat 24 (terpri))
(entdel (nth i entlst))
(setq txt (strcat (substr txt 1 (1- p)) (nth i txtlst) (substr txt p)))
(entmod (subst (cons 1 txt) (cons 1 old) (entget (nth txtlin entlst))))
(setq txtlst (insert (delete txtlst txtlin) txt txtlin)
txtlst (delete txtlst i) entlst (delete entlst i)
num (1- num) old txt len (strlen txt))
(if (< i txtlin) (setq txtlin (1- txtlin)))
(display)
(cursor)
)
(progn
(status)
(cursor)
)
)
)
(defun brktxt ()
(princ "\e[2J")
(repeat 24 (terpri))
(graphscr)
(setq new (substr txt p) txt (substr txt 1 (1- p)))
(while (not (setq p1 (getpoint "Start point: "))))
(setq entdata (entget (setq ent (nth txtlin entlst))))
(if (equal (setq p2 (cdr (assoc 11 entdata))) '(0.000000 0.000000))
(setq p2 (cdr (assoc 10 entdata)))
)
(command "COPY" ent "" p2 p1)
(entmod (subst (cons 1 txt) (cons 1 old) entdata))
(entmod (subst (cons 1 new) (cons 1 old) (entget (entlast))))
(setq old txt num (1+ num)
txtlst (insert (insert (delete txtlst txtlin) txt txtlin)
new (1+ txtlin))
entlst (insert entlst (entlast) (1+ txtlin))
)
(display)
(chglin 1)
)
(gc)
(if (setq ss (ssget))
(progn
(setq num (sslength ss))
(while (and (< i num) (< i 10))
(if (/= (cdr (assoc 0 (entget (setq ent (ssname ss i))))) "TEXT")
(progn
(ssdel ent ss)
(setq num (1- num))
)
(progn
(setq entlst (append entlst (list ent))
txtlst (append txtlst (list (cdr (assoc 1 (entget ent)))))
i (1+ i)
)
)
)
)
(setq num (length txtlst))
)
)
(if txtlst
(progn
(display)
(chglin 0)
(while (not (or (= (cadr (setq char (grread))) 27) (< num 1)))
(if (= (car char) 2)
(progn
(setq char (cadr char))
(if (not (or (< char 31) (> char 126)))
(if ins
(progn
(setq txt (strcat (substr txt 1 (1- p))
(princ (chr char))
(princ (substr txt p)))
)
(princ "\004")
(setq p (1+ p) len (1+ len))
(cursor)
)
(progn
(setq txt (strcat (substr txt 1 (1- p))
(princ (chr char))
(substr txt (1+ p)))
)
(if (> p len)
(progn
(setq len (1+ len))
(princ "\004")
)
)
(setq p (1+ p))
(cursor)
)
)
(cond
((not (or (/= char 7) (< p 2))) ; left
(progn
(setq p (1- p))
(cursor)
)
)
((not (or (/= char 15) (> p len))) ;right
(progn
(setq p (1+ p))
(cursor)
)
)
((= char 20) (mode ins)) ; ins
((not (or (/= char 2) (> p len))) ; del
(progn
(setq txt (strcat (substr txt 1 (1- p))
(princ (substr txt (1+ p))))
)
(princ "\004 ")
(setq len (1- len))
(cursor)
)
)
((not (or (/= char 8) (< p 2))) ; backspace
(progn
(setq p (1- p))
(cursor)
(setq txt (strcat (substr txt 1 (1- p))
(princ (substr txt (1+ p))))
)
(princ "\004 ")
(setq len (1- len))
(cursor)
)
)
((= char 189) (jointxt)) ; join F3
((= char 190) ; break F4
(if (not (or (< p 2) (>= p len) (> num 9)))
(brktxt)
)
)
((= char 143) ; shift tab
(progn
(if (= (/ (1- p) 5) (/ (1- p) 5.0))
(setq p (- p 5))
(setq p (1+ (* (/ (1- p) 5) 5)))
)
(if (< p 1) (setq p 1))
(cursor)
)
)
((= char 9) ; tab
(progn
(if (= (/ (1- p) 5) (/ (1- p) 5.0))
(setq p (+ p 5))
(setq p (+ 6 (* (/ (1- p) 5) 5)))
)
(if (>= p len) (setq p (1+ len)))
(cursor)
)
)
((= char 238) ; begin
(progn
(setq p 1)
(cursor)
)
)
((= char 239) ; end
(progn
(setq p (1+ len))
(cursor)
)
)
((= char 188) ; modify F2
(if (/= old txt)
(progn
(modtxt txtlin txt old)
(setq old txt)
(cursor)
)
)
)
((or (= char 4) (= char 13)) ; down F6
(if (and (< txtlin (1- num)) (< txtlin 10))
(chglin 1)
(chglin 0)
)
)
((not (or (/= char 191) (<= txtlin 0))) ; up F5
(chglin -1)
)
)
)
)
)
(if (< len 1) (deltxt))
)
(princ "\e[2J")
(repeat 24 (terpri))
(graphscr)
(if (/= old txt)
(entmod (subst (cons 1 txt) (cons 1 old) (entget (nth txtlin entlst))))
)
)
)
(command)
)